using System;
using DG.Tweening;
using UnityEngine;

[RequireComponent(typeof(RectTransform))]
public class MovingFx : MonoBehaviour
{
	public RectTransform m_RectTransform;

	private Sequence m_Sequence;

	public void Emit(Vector2 _TargetAnchorDestination, Action _OnCompleted = null)
	{
		Vector2 vector = new Vector2(UnityEngine.Random.Range(-1f, 1f), UnityEngine.Random.Range(-1f, 1f));
		m_RectTransform.localScale = Vector3.zero;
		float num = (float)Screen.width * 0.3f;
		Vector2 endValue = m_RectTransform.anchoredPosition + vector * num;
		m_RectTransform.DOScale(Vector3.one, 0.05f);
		m_Sequence = DOTween.Sequence();
		m_Sequence.AppendInterval(UnityEngine.Random.Range(0f, 0.2f));
		m_Sequence.Append(m_RectTransform.DOAnchorPos(endValue, 0.7f));
		m_Sequence.Append(m_RectTransform.DOAnchorPos(_TargetAnchorDestination, 0.5f));
		m_Sequence.Append(m_RectTransform.DOScale(Vector3.zero, 0.2f));
		m_Sequence.OnComplete(delegate
		{
			base.gameObject.SetActive(value: false);
			_OnCompleted?.Invoke();
		});
	}
}
